# @mindset-swiss/backup-to-sharepoint

> To upload a folder or file to a sharepoint folder

Latest version **2.0.4** (published 2021-06-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mindset-swiss/backup-to-sharepoint
pnpm add @mindset-swiss/backup-to-sharepoint
yarn add @mindset-swiss/backup-to-sharepoint
bun add @mindset-swiss/backup-to-sharepoint
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2021-06-21 |
| First published | 2021-06-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 (+24 in 2 direct dependencies) |
| Install scripts | no |
| Author | Avinash Naidu |
| Maintainers | mindset-swiss |

## Links

- npm: https://www.npmjs.com/package/@mindset-swiss/backup-to-sharepoint
- npm.io page: https://npm.io/package/@mindset-swiss/backup-to-sharepoint

## Dependencies (5)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [qs](https://npm.io/package/qs.md) ^6.10.1
- [mime](https://npm.io/package/mime.md) ^2.5.2
- [async](https://npm.io/package/async.md) ^3.2.0
- [axios](https://npm.io/package/axios.md) ^0.21.1

## Recent versions

- 2.0.4 (latest) — 2021-06-21
- 2.0.3 — 2021-06-21
- 2.0.2 — 2021-06-21
- 2.0.1 — 2021-06-21
- 2.0.0 — 2021-06-20
- 1.0.2 — 2021-06-18
- 1.0.1 — 2021-06-18
- 1.0.0 — 2021-06-18

## README

# @mindset-swiss/backup-to-sharepoint

To backup a folder or file to sharepoint folder using node js

## Install

```
$ npm install @mindset-swiss/backup-to-sharepoint
```

## Getting Started

1) Create a new app in the target directory (Azure Portal > Azure Active Directory > App Registration > New Application Registration).
2) In the Create screen, enter the following information:
Name: Can be any name, for example, "MicrosoftGraphClient."
Type: Must be "Web App/API" for our needs.
Sign-On URL: Not important (since we do not intend users to directly login to the app), for our case, we should put it under the tenant directory. For example,https://<directoryname>.onmicrosoft.com/MicrosoftGraphClient
3) Get the Client ID: Note the Application ID - It is the Client ID, so we need the following steps.
4) Create a new Client Secret: Navigate to App > Keys > Passwordsand add a new key.
    - Name (description): enter a descriptive name for the key so you later know that the client application is using it (you can have more than one key per app).
    - Expires: Choose "Never Expire," unless you want to change your key every year or two.
    - Click Save - a new Client Secret will be generated for you. This will be the only time you will see the Client Secret, so you better copy it to a secured location otherwise you won't be able to retrieve it again!
5) Grant permissions within the Azure console (application directory > API Permissions)
    - requires Microsoft Graph Files.ReadWrite.All
    - type Application
    - Then it will require the admin approval


By default each running of the app will create a new folder labeled as the current date, if the current date folder already exists it will update the same folders and create a new version of each file on sharepoint

## Usage

```js
const oneDriveBackup = require("@mindset-swiss/backup-to-sharepoint");

// To run a single backup
var failures = await oneDriveBackup.startBackup({
    backupFolderPath: '/home/ubuntu/Documents/.../FolderToBackup', // The path to the folders you wish to backup and deploy
    oneDriveFolderName: 'Project Backup',
    directoryID: "XXXXX", // Your unique directoryID (The directory name can be found by hovering over our name in the Azure Portal)
    driveID: "XXXXX", // Your unique driveID/name
    client_id: "XXXXX", // Miscrosoft App client ID
    client_secret: "XXXXX", // Miscrosoft App client Secret
});
// Depending on the size of your folders/files, this can take some time
//=> []  Will return an array with all the files which failed to uploaded

// To run a daily backup but only keep a 7 day history (delete based on folder name date) -- need to use a cron job to run it everday
oneDriveBackup.dailyBackup7Days(
    {
        backupFolderPath: '/home/ubuntu/Documents/.../FolderToBackup', // The path to the folders you wish to backup and deploy
        oneDriveFolderName: 'Project Backup',
        directoryID: "XXXXX", // Your unique directoryID (The directory name can be found by hovering over our name in the Azure Portal)
        driveID: "XXXXX", // Your unique driveID/name
        client_id: "XXXXX", // Miscrosoft App client ID
        client_secret: "XXXXX", // Miscrosoft App client Secret
    }
);

console.log(failures)

```

---
_Source: https://npm.io/package/@mindset-swiss/backup-to-sharepoint · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
